﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200013F RID: 319
	[Serializable]
	public class ConstraintRotationOffset : Constraint
	{
		// Token: 0x060004CB RID: 1227 RVA: 0x00015139 File Offset: 0x00013539
		public ConstraintRotationOffset()
		{
		}

		// Token: 0x060004CC RID: 1228 RVA: 0x00015141 File Offset: 0x00013541
		public ConstraintRotationOffset(Transform transform)
		{
			this.transform = transform;
		}

		// Token: 0x060004CD RID: 1229 RVA: 0x00015150 File Offset: 0x00013550
		public override void UpdateConstraint()
		{
			if (this.weight <= 0f)
			{
				return;
			}
			if (!base.isValid)
			{
				return;
			}
			if (!this.initiated)
			{
				this.defaultLocalRotation = this.transform.localRotation;
				this.lastLocalRotation = this.transform.localRotation;
				this.initiated = true;
			}
			if (this.rotationChanged)
			{
				this.defaultLocalRotation = this.transform.localRotation;
			}
			this.transform.localRotation = this.defaultLocalRotation;
			this.transform.rotation = Quaternion.Slerp(this.transform.rotation, this.offset, this.weight);
			this.lastLocalRotation = this.transform.localRotation;
		}

		// Token: 0x17000031 RID: 49
		// (get) Token: 0x060004CE RID: 1230 RVA: 0x00015213 File Offset: 0x00013613
		private bool rotationChanged
		{
			get
			{
				return this.transform.localRotation != this.lastLocalRotation;
			}
		}

		// Token: 0x0400020C RID: 524
		public Quaternion offset;

		// Token: 0x0400020D RID: 525
		private Quaternion defaultRotation;

		// Token: 0x0400020E RID: 526
		private Quaternion defaultLocalRotation;

		// Token: 0x0400020F RID: 527
		private Quaternion lastLocalRotation;

		// Token: 0x04000210 RID: 528
		private Quaternion defaultTargetLocalRotation;

		// Token: 0x04000211 RID: 529
		private bool initiated;
	}
}
